package com.niiwoo.civet.scheduler.trigger;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.trade.service.fund.FundJobDubboService;
import com.niiwoo.civet.trade.service.koala.KaoLaLiCaiDubboService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;

/**
 * 资金端 公共计划任务触发器
 *
 * @author lichuanzhi
 * @date 2018/01/26
 */

@Slf4j
@Component
public class FundJobTrigger {

    @Reference(version = "1.0.0")
    FundJobDubboService fundJobDubboService;

    @Reference(version = "1.0.0")
    KaoLaLiCaiDubboService kaoLaLiCaiDubboService;

    @Scheduled(cron = "${fund.update_penalty_fee}")
    public void updatePenaltyFeeJob() {
        log.info("fund updatePenaltyFeeJob start");
        CompletableFuture.runAsync(()-> fundJobDubboService.autoUpdatePenaltyAndProjectStatus());
    }

    @Scheduled(cron = "${fund.schedule_withhold}")
    public void scheduleWithholdJob() {
        log.info("fund scheduleWithhold start");
        CompletableFuture.runAsync(()-> kaoLaLiCaiDubboService.scheduleWithhold());
    }
}
